package com.uroad.jilinpda.util;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.widget.Toast;

import com.uroad.lib.util.log.LogUtil;

public class ToastUtil {
	private static final int SHOW_TIME = Toast.LENGTH_LONG;

	public static void show(Context context, String showString, int X, int Y) {
		try {
			if(!TextUtils.isEmpty(showString)){
				Toast toast = Toast.makeText(context, showString, SHOW_TIME);
				toast.setGravity(Gravity.TOP | Gravity.LEFT, X, Y);
				toast.show();
			}else{
				LogUtil.e("","showString -> null");
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
	}

	public static void show(Context context, String showString) {
		
		try {
			if(!TextUtils.isEmpty(showString)){
				Toast toast = Toast.makeText(context, showString, SHOW_TIME);
				toast.setGravity(Gravity.CENTER, 0, 0);
				toast.show();
			}else{
				LogUtil.e("","showString -> null");
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	public static void showShort(Context context, String showString) {
		try {
			if(!TextUtils.isEmpty(showString)){
				Toast toast = Toast.makeText(context, showString,
						Toast.LENGTH_SHORT);
				toast.setGravity(Gravity.CENTER, 0, 0);
				toast.show();
			}else{
				LogUtil.e("","showString -> null");
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	public static void show(Context context, float x, float y, String showString) {
		try {
			if(!TextUtils.isEmpty(showString)){
				Toast toast = Toast.makeText(context, showString, SHOW_TIME);
				toast.setMargin(x, y);
				toast.show();
			}else{
				LogUtil.e("","showString -> null");
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

}
